import request from '@/utils/request'

/**
 * 确认订单页
 * @param {*} data 
 */
export function getConfirmOrder(data) {
    return request({
      url: '/api/order/generateConfirmOrder',
      method: 'post',
      data
    })
}

/**
 * 下单
 * @param {*} data 
 */
export function confirmOrder(data) {
    return request({
      url: '/api/order/generateOrder',
      method: 'post',
      data
    })
}


/**
 * 获取订单列表
 * @param {*} data 
 */
export function getOrders(data) {
  return request({
    url: '/api/order/list',
    method: 'get',
    params: { status: data.status, pageNum: data.pageNum, pageSize: data.pageSize }
  })
}

/**
 * 获取订单详情
 * @param {*} data 
 */
export function orderDetail(id) {
  return request({
    url: `/api/order/detail/${id}`,
    method: 'get'
  })
}

/**
 * 去支付
 * @param {*} data 
 */
export function toPay(id) {
  return request({
    url: `/api/order/pay`,
    method: 'post',
    params: { id : id}
  })
}

/**
 * 取消订单
 * @param {*} data 
 */
export function toCancel(id) {
  return request({
    url: `/api/order/cancelUserOrder`,
    method: 'post',
    params: { id : id}
  })
}

/**
 * 退货申请
 * @param {*} data 
 */
export function toReturn(data) {
  return request({
    url: `/api/returnApply/create`,
    method: 'post',
    data
  })
}

/**
 * 确认收货
 * @param {*} data 
 */
export function toConfirm(id) {
  return request({
    url: `/api/order/confirmReceiveOrder`,
    method: 'post',
    params: { id : id}
  })
}
